package com.niit.spark.sql.test

import org.apache.spark.sql.{DataFrame, SparkSession}

/**
 * Date:2025/5/16
 * Author：Ys
 * Description:
 */
object GenerateParquet {

  def main(args: Array[String]): Unit = {
    //生成一个Parquet
    val spark = SparkSession.builder().appName("GenerateParquet").master("local[*]").getOrCreate()
    spark.sparkContext.setLogLevel("ERROR")
    import spark.implicits._

    val data = Seq(
      (1,"2025-01-01",100.5),
      (2,"2025-01-02",200.8),
      (3,"2025-01-03",150.2)
    )

    val dataFrame: DataFrame = spark.createDataFrame(data).toDF("id", "date", "value")
    dataFrame.write.parquet("input/sql/parquet")

    spark.stop()

  }

}
